package com.wus.gateway.controller;

import com.wus.common.core.domain.base.Result;
import com.wus.gateway.service.UserService;
import com.wus.system.request.LoginUserReq;
import com.wus.system.response.LoginUserResp;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 登录控制器
 * @Author: wus
 * @Date: 2024/12/17 18:18
 */
@RequiredArgsConstructor
@RequestMapping("/user")
@RestController
public class UserController {

    private final UserService userService;

    @PostMapping("/login")
    public Result<LoginUserResp> login(@Validated @RequestBody LoginUserReq req) {
        LoginUserResp result = userService.login(req);
        return Result.ok(result);
    }

    @GetMapping("/logout")
    public Result<Boolean> logout() {
        Boolean result = userService.logout();
        return Result.ok(result);
    }
}
